<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vuejs测试</title>
    <script src="Vue/vue.js"></script>
</head>
<body>
    <div id="app">
        <button v-on:click="num++">增加</button>
        <button @click="decrement">减少</button>
        <h2>num = {{num}}</h2>
        <div style="background-color: lightblue;width: 100px;height: 100px" @click="print('div 被点击了')">
            <button @click.stop="print('点击了button')">点我试试</button>
        </div>
        <br>阻止默认事件：<br>
        <a href="www.baidu.com" @click.prevent="print('点击了超链接')">百度</a>
    </div>
<script>
    var app = new Vue({
       el:"#app",
       data:{
           num:1
       },
       methods:{
           decrement(){
               this.num--;
           },
           print(str){
               console.log(str);
           }
       }
    });
</script>
</body>
</html>